#ifndef SLOWLOOP_H
#define SLOWLOOP_H

#include <common/Array.h>
#include <common/Runnable.h>
#include <common/Queue.h>
#include "states/state.h"
#include "states/statesave.h"

class EventManager;
class Route;
class ParamManager;
class LockableStorage;

class SlowLoop : public Runnable {
public:
	SlowLoop(EventManager *evtmgr, Route *route, ParamManager *parammgr, LockableStorage *storage);
	virtual ~SlowLoop();
	
private:
	virtual void run();
	void init();
	void doStateSave();
	bool restoreFSM();
	void restoreRoute();
	void checkEvents();
	void processEvents();

	EventManager *evtmgr_;
	Route *route_;
	ParamManager *parammgr_;
	Queue queue_;
	state::State* fsm_;
	Array<int> events_;
	StateSave statesave_;
};

#endif
